package src.main.java.org.arraylist;

import java.util.ArrayList;
import java.util.Scanner;

//负责完成菜品业务实现
public class FoodOperator {
    private ArrayList<Food> foodList = new ArrayList<>();

    public void addFood(){
        Food food = new Food();
        Scanner sc = new Scanner(System.in);
        System.out.println("请录入菜品名称：");
        String name = sc.nextLine();
        food.setName(name);

        System.out.println("请输入菜品价格：");
        double price = sc.nextDouble();
        food.setPrice(price);

        System.out.println("请输入菜品描述：");
        String desc = sc.nextLine();
        food.setDesc(desc);

        foodList.add(food);
        System.out.println("上架成功");
    }

    public void showAllFoods(){
        if(foodList.size()==0){
            System.out.println("目前尚未上架菜品");
        }
        for (int i = 0; i < foodList.size(); i++) {
            Food food = foodList.get(i);
            System.out.println("菜品的名称:"+food.getName());
            System.out.println("菜品的价格:"+food.getPrice());
            System.out.println("菜品的描述:"+food.getDesc());
            System.out.println("-----------------");
        }
    }
    public void start(){
        while (true) {
            System.out.println("请选择功能：");
            System.out.println("1.上架菜品");
            System.out.println("2.展示菜品");
            System.out.println("3.退出");
            Scanner sc = new Scanner(System.in);
            String choose = sc.next();
            switch (choose){
                case "1":
                    addFood();
                    break;
                case "2":
                    showAllFoods();
                    break;
                case "3":
                    System.out.println("下次再来");
                    return;
                default:
                    System.out.println("输入有误");
            }
        }

    }
}
